#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int a[10000] = { 0 };
int main()
{
	int L, M, m, n, count = 0;
	scanf("%d %d", &L, &M);

	for (int i = 0; i < M; i++)
	{
		scanf("%d %d", &m, &n);
		for (int j = m; j <= n; j++)
			a[j] = 1;
	}

	for (int k = 0; k <= L; k++)
		if (a[k] == 0)
			count++;

	printf("%d", count);
	return 0;
}